/*
 * Tencent is pleased to support the open source community by making KuiklyBase available.
 * Copyright (C) 2025 Tencent. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.tencent.kmm.network.curl

import com.tencent.kmm.network.export.IVBPBLog
import com.tencent.kmm.network.export.VBTransportBytesRequest
import com.tencent.kmm.network.export.VBTransportBytesResponse
import com.tencent.kmm.network.export.VBTransportGetRequest
import com.tencent.kmm.network.export.VBTransportGetResponse
import com.tencent.kmm.network.export.VBTransportPostRequest
import com.tencent.kmm.network.export.VBTransportPostResponse
import com.tencent.kmm.network.export.VBTransportStringRequest
import com.tencent.kmm.network.export.VBTransportStringResponse

object CurlRequestService {
    fun sendGetRequest(
        request: VBTransportGetRequest,
        handler: (response: VBTransportGetResponse) -> Unit,
        logTag: String = "CurlRequestService"
    ) {
        getCurlRequestService().get(request, handler, logTag)
    }

    fun sendPostRequest(
        request: VBTransportPostRequest,
        handler: (response: VBTransportPostResponse) -> Unit,
        logTag: String = "CurlRequestService"
    ) {
        getCurlRequestService().post(request, handler, logTag)
    }

    fun sendStringRequest(
        request: VBTransportStringRequest,
        handler: ((response: VBTransportStringResponse) -> Unit),
        logTag: String
    ) {
        getCurlRequestService().sendStringRequest(request, handler, logTag)
    }

    fun sendBytesRequest(
        request: VBTransportBytesRequest,
        handler: ((response: VBTransportBytesResponse) -> Unit),
        logTag: String
    ) {
        getCurlRequestService().sendBytesRequest(request, handler, logTag)
    }

    fun cancel(requestId: Int) {
        getCurlRequestService().cancel(requestId)
    }

    /**
     * libcurl 日志初始化接口
     */
    fun initNativeCurlLog(log: IVBPBLog) {
        getCurlRequestService().initNativeCurlLog(log)
    }
}

expect fun getCurlRequestService(): ICurlRequestService